package com.qingning.qn;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;

import com.ahj.apkupdata.APKUpdataPlugin;
import com.ahj.openFile.OpenFilePlugin;
import com.ahj.location.ChoiceLocationPlugin;
import com.ahj.permission.FlutterPermissionPlugin;

import aesEncode.AesEncodePlugin;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.android.FlutterView;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.imgselector.FlutterNativeImgPlugin;
import io.flutter.plugin.common.PluginRegistry;

import lbs.FlutterALbsMapPlugin;
import login.LogInPlugin;
import payPakage.aliPayPing.AliPayPlugin;
import payPakage.wxH5Play.WXH5PayPlugin;
import platformview.richview.MyPlatformViewPlugin;
import wxsdkPakage.WXJumpPlugin;
import wxsdkPakage.WXSharePlugin;
import zfbxcx.ZhiFuBaoXCXPlugin;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.analytics.MobclickAgent;
import io.flutter.plugins.GeneratedPluginRegistrant;

import webview.FlutterWebviewPlugin;

public class MainActivity extends FlutterActivity {

    public FlutterEngine flutterEngine;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!this.isTaskRoot()) {
            Intent mainIntent = getIntent();
            String action = mainIntent.getAction();
            if (mainIntent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {
                finish();
                return;
            }
        }
        UMConfigure.preInit(this, "63340b2c7d111470b13d9f86", "Umeng");
        UMConfigure.setLogEnabled(true);
        android.util.Log.i("UMLog", "UMConfigure.init@MainApplication");

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {

        this.flutterEngine = flutterEngine;
//        ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
//        ZhiBoPlugin.registerWith(flutterEngine,MainActivity.this);
        GeneratedPluginRegistrant.registerWith(flutterEngine);
        flutterEngine.getPlugins().add(new MyPlatformViewPlugin(MainActivity.this));
        ZhiFuBaoXCXPlugin.registerWith(flutterEngine, MainActivity.this);
        AesEncodePlugin.registerWith(flutterEngine, MainActivity.this);
        APKUpdataPlugin.registerWith(flutterEngine, MainActivity.this);
        FlutterPermissionPlugin.registerWith(flutterEngine, MainActivity.this);
        WXJumpPlugin.registerWith(flutterEngine, MainActivity.this);
        WXSharePlugin.registerWith(flutterEngine, MainActivity.this);
        AliPayPlugin.registerWith(flutterEngine, MainActivity.this);
        FlutterNativeImgPlugin.registerWith(flutterEngine, MainActivity.this);
        WXH5PayPlugin.registerWith(flutterEngine, MainActivity.this);
        OpenFilePlugin.registerWith(flutterEngine, MainActivity.this);
//        WXZhiBoPlugin.registerWith(flutterEngine, MainActivity.this);
        FlutterALbsMapPlugin.registerWith(flutterEngine, MainActivity.this);
//        WebViewFlutterPlugin.registerWith(flutterEngine);
        FlutterWebviewPlugin.registerWith(flutterEngine, MainActivity.this);
        LogInPlugin.registerWith(flutterEngine, MainActivity.this);
        ChoiceLocationPlugin.registerWith(flutterEngine, MainActivity.this);
//        flutterEngine.getPlugins().add(new VideoPlayerPlugin());
//        VideoPlayerPlugin.registerWith(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
        android.util.Log.i("UMLog", "onPause@MainActivity");
    }


    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
//        FlutterView flutterView = findViewById(FLUTTER_VIEW_ID);
//        flutterView.requestFocus();
        android.util.Log.i("UMLog", "onResume@MainActivity");
    }

}
